/*
Copyright 2008  Four Roads LLC conact@4-roads.com

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either 
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Web;
using System.Web.Util;
using System.Collections;
using System.Data;
using System.Xml;
using CommunityServer.Components;
using ResourceManager = FourRoads.Links.Controls.ResourceManager;

namespace FourRoads.Links
{
	/// <summary>
	/// Summary description for ResLinkApplication.
	/// </summary>
	public class ResLinkApplication : CSApplicationData
	{
		public override string Home
		{
			get{ return ResLinkUrls.Instance().ViewSection(-1);}
		}

		public override string SectionUrl(IContent ic)
		{
			if(ic != null)
			{
				IndexPost ip = ic as IndexPost;
			
				if(ip != null)
					return ResLinkUrls.Instance().ViewSection(ip.SectionID);

				ResLinkLink fp = ic as ResLinkLink;
		
				if(fp != null)
					return ResLinkUrls.Instance().ViewSection(fp.SectionID);
			}

			return string.Empty;
		}

		public override string PostName
		{
			get
			{
				return ResourceManager.GetString("ResLinkApplication_Post");
			}
		}

		public override string SectionName
		{
			get
			{
				return ResourceManager.GetString("ResLinkApplication_Section");
			}
		}

		public override string GroupName
		{
			get
			{
				return ResourceManager.GetString("ResLinkApplication_Group");
			}
		}

		public override string CategoryName
		{
			get
			{
				return ResourceManager.GetString("ResLinkApplication_Category");
			}
		}

		#region Favorite Text

		public override string AddFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_ResLink_AddPost");
			}
		}

		public override string RemoveFavoritePostText
		{
			get
			{
				return ResourceManager.GetString("Favorites_ResLink_RemovePost");
			}
		}

		public override string AddFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_ResLink_AddSection");
			}
		}

		public override string RemoveFavoriteSectionText
		{
			get
			{
				return ResourceManager.GetString("Favorites_ResLink_RemoveSection");
			}
		}

		#endregion

		public override IList Groups()
		{
			return new ArrayList();
		}

		public override IList Sections()
		{
			//Need to return a list of all of the sections that are resource link sections
			return ResLinkSection.GetAllSections();
		}

		public override IList SectionsByGroup(int groupID)
		{
			return  ResLinkSection.GetAllSections();
		}

		public override ApplicationType ApplicationType
		{
			get { return (ApplicationType)ExApplicationType.ResLink; }
		}

		public override string Name
		{
			get { return ResourceManager.GetString("ResLinks_AppName"); }
		}

		public override string Url(Post post)
		{
			return ResLinkUrls.Instance().ViewLink(post.SectionID , post.PostID);
		}

		public override Post InstantiatePost(IDataReader dr)
		{
			return DataProvider.ResLinkDataProvider.CreateLinksInformationFromIDataReader(dr);
		}

		public override Post GetPost(int postID)
		{
			return ResLinkLink.GetSingleLink(postID);
		}

		public override bool Enabled
		{
			get 
			{ 
				return ResLinkConfiguration.Instance().Enabled;
			}
		}

		public override void SetEnabledStatus(bool enabled)
		{
			ResLinkConfiguration config = ResLinkConfiguration.Instance();
			config.Enabled = enabled;
			config.Save();
		}

	}
}
